{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0;
        margin-top: 0
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                                                {in name='admin.type' value="1,2"}
                    <div class="fixed-table-toolbar" style="text-align: center;margin-bottom: 20px">
                        <h2>总提现: <span style="color: #1ab394; ">{:number_format($sum, 2)}</span></h2>
                        <p style="color:red;font-size: 18px;margin-top: 5px;">请务必进行历史收益对账后再审核,确保收益无异常！</p>
                    </div>
                                                {/in}

                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='type'}{else /}asdlkjasd{/present}" href="{:url('tixian_zfb')}">全部</a>
                        <!--<a class="btn btn-default btn-outline {eq name='type' value='1'}asdlkjasd{/eq}" href="{:url('tixian_zfb',['type'=>1])}">微信</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='2'}asdlkjasd{/eq}" href="{:url('tixian_zfb',['type'=>2])}">支付宝</a>-->
                        <a class="btn btn-default btn-outline {eq name='type' value='3'}asdlkjasd{/eq}" href="{:url('tixian_zfb',['type'=>3])}">审核</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='4' and name='daochu' value='2'}asdlkjasd{/eq}" href="{:url('tixian_zfb',['type'=>4,'daochu'=>2])}">未导出</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='4' and name='daochu' value='1'}asdlkjasd{/eq}" href="{:url('tixian_zfb',['type'=>4,'daochu'=>1])}">已导出</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='5'}asdlkjasd{/eq}" href="{:url('tixian_zfb',['type'=>5])}">拒绝</a>
                    </div>
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="userid" {php}if(input('?param.search')){if(input('param.search')=='userid'){echo "selected";} }{/php}>会员ID</option>
                                        <option value="name" {php}if(input('?param.search')){if(input('param.search')=='name'){echo "selected";} }{/php}>昵称</option>
                                        <option value="zhifuname" {php}if(input('?param.search')){if(input('param.search')=='zhifuname'){echo "selected";} }{/php}>收款人名称</option>
                                        <option value="zhifucount" {php}if(input('?param.search')){if(input('param.search')=='zhifucount'){echo "selected";} }{/php}>支付宝账户</option>
                                        <option value="order_no" {php}if(input('?param.search')){if(input('param.search')=='order_no'){echo "selected";} }{/php}>提现订单号</option>
                                    </select>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>

                                <input name="start" type="text" id="start" class="form-control layui-input" value="{present name='start'}{$start}{/present}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <input name="end" type="text" id="end" class="form-control layui-input" value="{present name='end'}{$end}{/present}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('tixian_zfb')}">返回列表</a>
                                </div>{php}
                                }
                                {/php}
                                

                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>                               
                                    <th data-align="center">用户</th>
                                    <th data-align="center">提现积分</th>
                                    <th data-align="center">手续费积分</th>
                                    <th data-align="center"><span style="color:blue;font-weight:bold;">提现金额</span></th>
                                    <th data-align="center">方式</th>
                                    <th data-align="center">姓名</th>
                                    <th data-align="center">账号</th>
                                    <th data-align="center">单号</th>
                                    <!--<th data-align="center">处理描述</th>-->
                                    <th data-align="center">审核</th>
                                    <th data-align="center">创建时间</th>
                                    <th data-align="center">审核时间</th>
                                    <th data-align="center">管理</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {php}
                                $qualitys = ['未检出','低端','一般','优质','超优质'];
                                {/php}
                                        
                                {php}$hide=array('0'=>'<font color="#f00">禁止</font>','1'=>'<font color="#1ab394">正常</font>','2'=>'审核','3'=>'<font color="#f00">拒绝</font>');{/php}
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td>{$v.id}</td>
                                    <td><a onclick="member('{$v.userid}')" style="color:#40BCF7">{$v.name}({$v.userid})({$qualitys[$v.quality]??''})</a></td>
                                    <td>{$v.price}</td>
                                    <td>{$v.shouxu}</td>
                                    <td><span style="color:blue;font-size: 15px;">{$v.money}</span></td>
                                    <?php $datas = json_decode($v['data'], true); ?>
                                    <td>
                                        {switch name="v.paymethod"}
                                            {case value="0"}微信{/case}
                                            {case value="1"}支付宝{/case}
                                            {case value="2"}银行卡{/case}
                                        {/switch}
                                    </td>
                                    <td>{if condition='isset($datas["name"])'} {$datas.name} {/if} </td>
                                    <td>{if condition='isset($datas["account"])'} {$datas.account} {if condition='isset($datas["name"]) && isset($datas["bank_user_name"])'} {$datas.bank_user_name} {/if}{/if}</td>
                                    <td>{$v.order_no}</td>
                                    <!--<td>{if condition='$v.state == 2'}{$v.reason}{/if}</td>-->
                                    <td>
                                        {switch name="v.state"}
                                            {case value="0"}审核{/case}
                                            {case value="1"}成功{/case}
                                            {case value="2"}拒绝{/case}
                                        {/switch}
                                    </td>
                                    <td><span {if condition="date('Ymd')==date('Ymd',$v.create_time)"}style="color: #ed5565"{/if}>{:date('Y-m-d H:i:s', $v.create_time)}</span></td>
                                    <td><span {if condition="date('Ymd')==date('Ymd',$v.update_time)"}style="color: #ed5565"{/if}>{:date('Y-m-d H:i:s', $v.update_time)}</span></td>
                                    <td>
                                        
                                    {switch name="v.state"}
                                        {case value="0"}
                                            <div onclick="x_admin_show('支付宝提现审核','{:url('tixianadd',['id'=>$v['id'],'url'=>-1])}')" class="btn btn-warning btn-xs">审核</div>
                                        {/case}
                                    {/switch}
                                    {if condition="$v.zhifubao_export_no neq null and $v.zhifubao_export_no neq '' and $daochu eq 1"}
                                        {switch name="v.txstate"}
                                        {case value="0"}
                                        <div onclick="x_admin_show('支付宝实际打款设置','{:url('tixian_zfbdk',['id'=>$v['id'],'url'=>-1])}')" class="btn btn-warning btn-xs">打款设置</div>
                                        {/case}
                                        {case value="1"}
                                        <div class="btn btn-success btn-xs" style="cursor:normal;">成功</div>
                                        {/case}
                                        {case value="2"}
                                        <div class="btn btn-danger btn-xs" style="cursor:normal;">失败</div>
                                        {/case}
                                        {default /}
                                        <div class="btn btn-default btn-xs" style="cursor:normal;">未知</div>
                                        {/switch}
                                        {/if}
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6">
                    {eq name="$type" value="4" and name="$daochu" value="2"}
                    <div  class="btn btn-outline btn-default" onclick="exportWithdrawMerge(0)">
                        <!--导出已合并未提现的数据-->
                        批量导出
                    </div>
                    {/eq}
                    {eq name="$type" value="4" and name="$daochu" value="1"}
                    <div  class="btn btn-outline btn-default" onclick="pldkok_zfb()">
                        批量打款成功
                    </div>
                    {/eq}
                </div>
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
<div id="tiianreject" style="text-align:center;display:none;margin: 0px 30px;padding:10px 100px">
    <div style="margin-bottom:10px"></div>
    <input type="text" id="tixianrejectvalue" class="form-control layui-input" value="" autocomplete="off" placeholder="拒绝原因">
</div>
{include file="public/footer" /}

<script type="text/javascript">

    $(document).ready(function(){

        $('#delidAll').click(function(){
            $('input[type=checkbox]').each(function(){
                var self=$(this);
                if(!self.prop('checked')){
                    self.prop('checked',true);
                }else{
                    self.prop('checked',false);
                }
            });
        })
    });

    layui.use(['laydate'], function(){
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });

        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });
    })

function del(id){
    swal_del(id,"{:url('tixiandel')}")
}

/*弹出层*/
/*
    参数解释：
    title   标题
    url     请求的url
    id      需要操作的数据id
    w       弹出层宽度（缺省调默认值）
    h       弹出层高度（缺省调默认值）
*/
function x_admin_show(title,url,w,h)
{
    if (title && title.includes('审核')) {
        if (!confirm('请务必进行历史收益对账后再审核,确保收益无异常！')) {
            // 用户点击了"取消"，阻止后续操作
            return false;
        }
    }
    if (title == null || title == '') {
        title=false;
    };
    if (url == null || url == '') {
        url="404.html";
    };
    if (w == null || w == '') {
        w=($(window).width()*0.9);
    };
    if (h == null || h == '') {
        h=($(window).height() - 50);
    };
    layer.open({
        type: 2,
        area: [w+'px', h +'px'],
        fix: false, //不固定
        maxmin: true,
        shadeClose: true,
        shade:0.4,
        title: title,
        content: url,
        end: function (){
            window.location.reload();
        }

    });
}

function member(id)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("index")}?search=id&name='+id
        });
    });
}

    function exportWithdrawMerge(x) {
        // 显示确认对话框
        if (confirm('导出后将变更未提现状态为已提现状态，确定导出吗！')) {
            var url = "<?php echo $_SERVER['REQUEST_URI']; ?>";
            var delAll = $(".form-horizontal").serialize();
            // 用户点击"确定"后执行导出
            window.location.href = '{:url("Export/WithdrawMerge")}?' + delAll + '&url=' + url;
        } else {
            // 用户点击"取消"，不执行任何操作
            return false;
        }
    }



    function pldkok_zfb(obj, id) {
        let alls=$(".form-horizontal").serializeArray();
        if(alls.length == 0){
           return layer.msg('请选择需要设置的项', {icon: 0});
        }
        let ids = []
        alls.forEach(item=>{
            ids.push(item.value)
        })
        //console.log(ids)
        $.ajax({
            type: 'POST',
            url: "{:url('admin/member/pldkok_zfb')}",
            data: {ids: ids.join(',')},
            dataType: 'json',
            success: function (date) {
                if (date.ret) {
                    layer.msg(date.ret, {icon: 6});
                    setTimeout(() => {
                    window.location.reload(); // 延迟刷新，确保提示显示完整
                    }, 1000);
                } else {
                    layer.msg(date.err, {icon: 0});
                }
            },
            error: function (e) {
                layer.msg(e.responseText);
            }
        });
    }

</script>

 